/**
 * CarGasProblem.java created by zhangzhidong 
 * at 下午10:24:38 2015年11月3日
 */
package algorithm;

import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author zhangzhidong
 *
 */
class MyObj{}
class Father extends MyObj{
	
}
class Sub extends Father{
	
}

public class CarGasProblem {
	//select distinct dept from table group by dept having count(*)>2
	//select dept,count(B) as 数量 from table group by dept 
	//update set ds = ds +5 where id = XX;
	
	/**
	 * 下午10:24:38 2015年11月3日
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		solution(new int[]{1,2,3,4,5,1,6,6},7);
		List<Sub> l1 = new ArrayList<Sub>();
		List<MyObj> l2 = new ArrayList<MyObj>();
		Collections.copy(l2, l1);
		ExecutorService execs = Executors.newFixedThreadPool(4);
		Socket s;

	}
	public static void solution(int dist[],int k){
		int numstops = dist.length-1;
		for(int i = 0;i<dist.length;i++){
			if(dist[i]>k){
				System.out.println("No Solution");
				return;
			}
		}
		int sum = 0;
		int num = 0;
		for(int i =  0;i<=numstops;i++){
			sum+=dist[i];
			if(sum>k){
				num++;
				sum=dist[i];
			}
		}
		System.out.println("停车"+num+"次");
	}

}
